Repository navigation
Migrate from requests to httpx2 - #4560
Merged
Merged
Conversation
APIClient now times out (15s connect, 600s otherwise), follows redirects as before, and wraps all request errors in ClientError. http+unix:// server URLs keep working, so requests-unixsocket is no longer needed.
AsyncClientWrapper closed the client from __del__, which needs a running loop and leaves the close task unreferenced.
Runner and shim clients are created per call, and loading the CA bundle takes about 5 ms on Linux.
Closing a client under an in-flight request can fail it with an error other than httpx2.RequestError, which bypasses failover to other replicas.
…ning Connections to the same gateway share the SSH control socket, so the second close could close a replacement's tunnel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #4427: moves dstack's own HTTP code from
requeststo httpx2.requestsremains only through python-dxf for Docker registries.HTTPClientandAsyncHTTPClientbase classes with a required timeout, adstack/<version>User-Agent, and system CA trust with the certifi fallback, and use them for all httpx2 clients.requests-unixsocket(http+unix://server URLs still work).APIClientretries only connection failures and raises only dstack errors, including for non-JSON 400 and 422 responses.close()and context manager support toAPIClientandClient.__del__, stop closed gateway connections from being used or reopened, clean up gateway connections that fail to open without touching a replacement, and close evicted gateway server clients once their requests finish.dstack loginon request errors and invalid URLs.requests_mockwith anhttp_mockfixture for httpx2 in tests.Performance
Breaking changes
REQUESTS_CA_BUNDLEandCURL_CA_BUNDLEno longer apply andSSL_CERT_FILEorSSL_CERT_DIRreplace them, and macOS verification may reject some private certificates that OpenSSL accepted.ALL_PROXYwith a SOCKS proxy requires thesocksiopackage (pip install "httpx2[socks]") instead of PySocks.t).